00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OggFLACPP__ENCODER_H
00021 #define OggFLACPP__ENCODER_H
00022
00023 #include "export.h"
00024
00025 #include "OggFLAC/stream_encoder.h"
00026 #include "decoder.h"
00027
00028 #include "FLAC++/decoder.h"
00029 #include "FLAC++/encoder.h"
00030
00031
00059 namespace OggFLAC {
00060 namespace Encoder {
00061
00062
00063
00064
00065
00066
00067
00081 class OggFLACPP_API Stream {
00082 public:
00083 class OggFLACPP_API State {
00084 public:
00085 inline State(::OggFLAC__StreamEncoderState state): state_(state) { }
00086 inline operator ::OggFLAC__StreamEncoderState() const { return state_; }
00087 inline const char *as_cstring() const { return ::OggFLAC__StreamEncoderStateString[state_]; }
00088 protected:
00089 ::OggFLAC__StreamEncoderState state_;
00090 };
00091
00092 Stream();
00093 virtual ~Stream();
00094
00095 bool is_valid() const;
00096 inline operator bool() const { return is_valid(); }
00097
00098 bool set_serial_number(long value);
00099 bool set_verify(bool value);
00100 bool set_streamable_subset(bool value);
00101 bool set_do_mid_side_stereo(bool value);
00102 bool set_loose_mid_side_stereo(bool value);
00103 bool set_channels(unsigned value);
00104 bool set_bits_per_sample(unsigned value);
00105 bool set_sample_rate(unsigned value);
00106 bool set_blocksize(unsigned value);
00107 bool set_max_lpc_order(unsigned value);
00108 bool set_qlp_coeff_precision(unsigned value);
00109 bool set_do_qlp_coeff_prec_search(bool value);
00110 bool set_do_escape_coding(bool value);
00111 bool set_do_exhaustive_model_search(bool value);
00112 bool set_min_residual_partition_order(unsigned value);
00113 bool set_max_residual_partition_order(unsigned value);
00114 bool set_rice_parameter_search_dist(unsigned value);
00115 bool set_total_samples_estimate(FLAC__uint64 value);
00116 bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
00117
00118 State get_state() const;
00119 FLAC::Encoder::Stream::State get_FLAC_stream_encoder_state() const;
00120 FLAC::Decoder::Stream::State get_verify_decoder_state() const;
00121 void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
00122 bool get_verify() const;
00123 bool get_streamable_subset() const;
00124 bool get_do_mid_side_stereo() const;
00125 bool get_loose_mid_side_stereo() const;
00126 unsigned get_channels() const;
00127 unsigned get_bits_per_sample() const;
00128 unsigned get_sample_rate() const;
00129 unsigned get_blocksize() const;
00130 unsigned get_max_lpc_order() const;
00131 unsigned get_qlp_coeff_precision() const;
00132 bool get_do_qlp_coeff_prec_search() const;
00133 bool get_do_escape_coding() const;
00134 bool get_do_exhaustive_model_search() const;
00135 unsigned get_min_residual_partition_order() const;
00136 unsigned get_max_residual_partition_order() const;
00137 unsigned get_rice_parameter_search_dist() const;
00138 FLAC__uint64 get_total_samples_estimate() const;
00139
00140 State init();
00141
00142 void finish();
00143
00144 bool process(const FLAC__int32 * const buffer[], unsigned samples);
00145 bool process_interleaved(const FLAC__int32 buffer[], unsigned samples);
00146 protected:
00147 virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame) = 0;
00148
00149 ::OggFLAC__StreamEncoder *encoder_;
00150 private:
00151 static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
00152
00153
00154 Stream(const Stream &);
00155 void operator=(const Stream &);
00156 };
00157
00158
00159
00160 };
00161 };
00162
00163 #endif